Repository navigation
util_viewer reads wallclock's breakdown by its own names; Inductor's FX cache key names the machine - #430
Merged
Conversation
…k's own names
The viewer looked for breakdown.json and read its compile records under
"the compiler" (a leftover of a blanket rename); wallclock writes
breakdown_<run>.json and keys the records "torchsim-compile". So --breakdown
over a dump path found nothing, and given the file by name
timing_from_breakdowns returned {} and torchsim-compile sorted after spike.
wallclock now writes the records under TORCHSIM_COMPILE and states its group
order as GROUPS; util_viewer imports wallclock and reads PREFIX,
TORCHSIM_COMPILE and GROUPS from it.
tests/system/test_breakdown_viewer.py writes a breakdown through wallclock
(span, ingest_compile, the exit hook) and reads it with the viewer. On the
parent: find_breakdowns(dump) == [], timing_from_breakdowns(file) == {},
groups ['spike', 'torchsim-compile', 'elsewhere']. Added to the CI matrix.
Refs #426
NPUChoices.uuid() was "pytorchsim-npu-choices-3-" + record_digest(), and the digest is "none" for any machine with no recorded picks, so every such TORCHSIM_TARGET handed Inductor the same FX cache key and reused another machine's cached graphs, though tiling and reduction_split_factor read the machine. select.graph_digest() digests the target's name, target().as_dict() and num_cores together with record_digest(); uuid() is "pytorchsim-npu-choices-4-" + that digest. test_select.test_graph_cache_key_names_the_machine loads three machine files named m.yml (tpuv6e as is, num_cores 2, vpu_spad_size_kb_per_lane 512) with no record; on the parent all three uuids are 'pytorchsim-npu-choices-3-none'. Refs #426
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #426
Why
Two readers disagreed with the code that writes their input:
scripts/util_viewer.pylooked forbreakdown.jsonand read compile records under"the compiler"(a leftover of a blanket rename).pytorchsim/simulator/wallclock.pywritesbreakdown_<run-id>.json(the_at_exithook) and keys the records"torchsim-compile". So--breakdown <dump>found nothing, and given the file by nametiming_from_breakdownsreturned{}andtorchsim-compilesorted afterspike.NPUChoices.uuid()(pytorchsim/frontend/inductor_patches.py) was"pytorchsim-npu-choices-3-" + record_digest(). The digest is"none"for any machine with no recorded picks, so every suchTORCHSIM_TARGETgave Inductor the same FX graph cache key and reused another machine's cached graphs, even though tiling andreduction_split_factorread the machine. Torch builds the key frominductor_choices_class().uuid()(torch/utils/_config_module.py:678,_cache_config_factory_keys).What changed (before -> after)
c88e7a8[Tools] util_viewer reads the breakdown wallclock writes, by wallclock's own nameswallclock.py: records written under theTORCHSIM_COMPILEconstant; newGROUPS(derived fromORDER) replaces the two hard-coded group tuples inrender. Pure refactor:GROUPS == ('torchsim-compile','spike','gem5','togsim'), the same tuples as before.util_viewer.py: importspytorchsim.simulator.wallclock(no torch import) and readsPREFIX,TORCHSIM_COMPILE,GROUPSfrom it — one name per concept. Search patternbreakdown.json->breakdown*.json(still matches an oldbreakdown.json).tests/system/test_breakdown_viewer.py, added to the matrix in.github/workflows/pytorchsim_test.yml.56142ad[Frontend] Inductor's graph cache key names the machinepytorchsim/driver/select.py: newgraph_digest()= sha256 over the target's name,target().as_dict(),num_coresandrecord_digest(); machine part isNoneonNoTarget.inductor_patches.py:uuid()="pytorchsim-npu-choices-4-" + graph_digest().test_graph_cache_key_names_the_machineintests/system/test_select.py: three machine files all namedm.yml(tpuv6e as is,num_cores=2,vpu_spad_size_kb_per_lane=512), no recorded picks.Tests (parent
069878avs branch56142ad)test_breakdown_viewer.test_viewer_finds_the_file_wallclock_writesfind_breakdowns(dump) == []test_breakdown_viewer.test_viewer_reads_the_compile_recordstiming_from_breakdowns == {}, groups['spike','torchsim-compile','elsewhere']test_select.test_graph_cache_key_names_the_machinepytorchsim-npu-choices-3-noneThe cache-key pin is not vacuous: all three machines share the name
m;num_coresis not inas_dict()(PTBcontract/target.py:186), so dropping it from the digest fails the cores case; droppingas_dictfails the spad case.Verification
Container from
topk-ptb:pts-base-92028c8(compiler at92028c8, not the pin1b35878; these checks only use its target module and the add smoke). Independently re-run by a reviewer in a separate worktree/container.test_selecttest_a_refused_config…andtest_a_config_running_past_the_cut…pass;tests/system/test_patch_scope.pypasses (after buildingdevice/asdocker/Dockerfiledoes);tests/ops/elementwise/test_add.pywithTORCHSIM_BREAKDOWN=1: rc=0, 5 passed. On that dump the viewer found the realbreakdown_<run>.json, read compile records keyed by kernel, groups['torchsim-compile','spike','elsewhere'].util_viewer.py --helpworks when run from/.test_select_record_and_rebuild, full suites.Stacking / dependencies
Based on
origin/pytorchsim-triton-backendat069878a, which already contains #421 and #423 — not stacked. PTB pin1b35878unchanged.Open issues
{name, as_dict, num_cores}. In timing mode TOGSim reads machine-file keys outsideas_dict(DRAM, NoC, …), so two machines differing only there still share a key.select.identity()(select.py:181) andcodecache.identity()(codecache.py:160) useas_dicttoo, so this is consistent with existing design; follow-up candidate: digest the machine file itself.scripts/util_viewer.py:8,:1134("the the compiler"),--timinghelp near:1218;codecache.py:89docstring;codecache.py:158build-stamp key"the compiler"(a separate concept — written and compared by the same function; renaming it would make every cached stamp miss)..claude/CLAUDE.mdis stale: the test list at line 99 lackstest_breakdown_viewer, line 182 saysbreakdown.json.util_viewer.pynow importspytorchsim.config(needs PyYAML) via asys.pathinsert (util_viewer.py:26-27).🤖 Generated with Claude Code
https://claude.ai/code/session_01UnJWSTNtd6944XAzy4bhk5